refactor(vnext): extract realm-neutral parser backend - #179
Conversation
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Pull request overview
This PR refactors the vNext node-sql-parser integration by extracting module decoding, parser invocation, output validation, and error normalization into a new internal realm-neutral backend, while keeping Node-specific realm validation and module loading in the existing adapter.
Changes:
- Added
createNodeSqlParserBackendas a realm-neutral engine with standardized outcomes, retry caching, and cancellation checkpoints. - Rewired the Node adapter to delegate parsing to the backend while preserving Node-only responsibilities (realm validation, module loading/cleanup, authority, and AST ownership).
- Added comprehensive backend contract tests and expanded docs to clarify the host/engine responsibility boundary.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/vnext/node-sql-parser-backend.ts | New realm-neutral backend implementing module decoding, parsing, validation, normalized outcomes, and retry caching. |
| src/vnext/node-sql-parser-adapter.ts | Refactor to delegate parsing to the new backend while retaining Node-specific realm checks and module loading. |
| src/vnext/tests/node-sql-parser-backend.test.ts | New exhaustive tests covering backend contract behavior, hostile values, caching, and ambient neutrality. |
| docs/vnext/node-sql-parser-adapter.md | Documentation update describing the new backend/adapter responsibility split. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
1 issue found and verified against the latest diff
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/vnext/node-sql-parser-backend.ts">
<violation number="1" location="src/vnext/node-sql-parser-backend.ts:110">
P3: Hostile-property decoding now has two independent implementations in the backend and adapter, so fixes to descriptor/proxy handling can drift between their module boundaries. A shared realm-neutral property-reader utility would preserve the same behavior in both paths.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| return typeof value === "object" && value !== null; | ||
| } | ||
|
|
||
| function readOwnDataProperty( |
There was a problem hiding this comment.
P3: Hostile-property decoding now has two independent implementations in the backend and adapter, so fixes to descriptor/proxy handling can drift between their module boundaries. A shared realm-neutral property-reader utility would preserve the same behavior in both paths.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/vnext/node-sql-parser-backend.ts, line 110:
<comment>Hostile-property decoding now has two independent implementations in the backend and adapter, so fixes to descriptor/proxy handling can drift between their module boundaries. A shared realm-neutral property-reader utility would preserve the same behavior in both paths.</comment>
<file context>
@@ -0,0 +1,427 @@
+ return typeof value === "object" && value !== null;
+}
+
+function readOwnDataProperty(
+ value: object,
+ key: PropertyKey,
</file context>
|
Cubic P3 disposition: no code change. The two descriptor readers are deliberately boundary-owned and do not share one semantic contract. The Node adapter inspects inherited realm aliases ( |
Summary
No public export, session wiring, worker protocol, or user-visible API is added.
Validation
Independent review
Two independent adversarial reviewers approved exact commit 96bd2ce with zero actionable findings.
Summary by cubic
Extracted a new internal backend for
node-sql-parserand rewired the Node adapter to call it. No public API changes.Refactors
node-sql-parser-backend: decodes module, runsastify, validates output, and normalizes errors; no Node/window/worker refs.requireloading, cleanup, parser authority, and private AST ownership; uses backend outcomes.MAX_NODE_SQL_PARSER_STATEMENT_LENGTH.default/module.exports/namedParser; ignores accessors/proxies and redacts private data.Bug Fixes
Written for commit 08a9d67. Summary will update on new commits.